#ifndef __GAME_PLAY_LAYER__
#define __GAME_PLAY_LAYER__

#include "cocos2d.h"
#include "cocos-ext.h"
USING_NS_CC;
USING_NS_CC_EXT;

enum MenuType
{
	MT_START,
	MT_GAMEOVER,
};

enum GameState
{
	GS_MENU_START,
	GS_GAME_OVER,
	GS_PLAY,
};

class GamePlayLayer : public CCLayer
{
public:
	GamePlayLayer();
	~GamePlayLayer();

	bool init();
	CREATE_FUNC(GamePlayLayer);
	
	void setState(int state);

private:
	// game value
	int leftOperator;
	int rightOperator;
	int result;
	bool isCorrect;

	int level;
	int state;
	float remainTime;

	// controls
	CCLabelTTF* scoreLabel;
	CCLabelTTF* highScoreLabel;
	CCSprite* timeSprite;
	CCSprite* failSprite;

	CCControlButton* replayButton;
	CCControlButton* highScoreButton;
	CCControlButton* voteButton;

	CCControlButton* trueButton;
	CCControlButton* falseButton;

	CCLabelTTF* bigTextLabel;
	CCLabelTTF* calculationLabel;
	CCLabelTTF* resultLabel;
	
	CCPoint scoreOriginLocation;
	CCPoint highScoreOriginLocation;
	CCPoint trueButtonOriginLocation;
	CCPoint falseButtonOriginLocation;

	// game func
	void generateNewQuestion();
	void newQuestion();
	void resetGame();

	// ui func
	CCSprite* backgroundSprite;
	void draw();
	void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
	bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
	void replayButtonTouched(CCObject* sender, CCControlEvent event);
	void highScoreButtonTouched(CCObject* sender, CCControlEvent event);
	void voteButtonTouched(CCObject* sender, CCControlEvent event);
	void trueButtonTouched(CCObject* sender, CCControlEvent event);
	void falseButtonTouched(CCObject* sender, CCControlEvent event);
	void preloadSound();
	void update(float delta);
	void createMenu();
	void showMenu(int menuType);
	void hideMenu();
	void showGameControls(bool isShowGameControls);
	void createGameControls();
	void updateScoreUi();
	void changeToGameMenuSchedule(float delta);
	void changeToGameOverState();
	void changeToMenuState();
};
#endif // !__GAME_PLAY_LAYER__
